home *** CD-ROM | disk | FTP | other *** search
/ SGI Origin & Onyx2 Patches 1998 May / Origin and Onyx2 System Disk Patches May 1998.img / dist / patchSG0002839.idb / usr / include / sys / syscall.h.z / syscall.h
C/C++ Source or Header  |  1998-04-01  |  7KB  |  247 lines

  1. /**************************************************************************
  2.  *                                      *
  3.  *          Copyright (C) 1990-1995 Silicon Graphics, Inc.          *
  4.  *                                      *
  5.  *  These coded instructions, statements, and computer programs  contain  *
  6.  *  unpublished  proprietary  information of Silicon Graphics, Inc., and  *
  7.  *  are protected by Federal copyright law.  They  may  not be disclosed  *
  8.  *  to  third  parties  or copied or duplicated in any form, in whole or  *
  9.  *  in part, without the prior written consent of Silicon Graphics, Inc.  *
  10.  *                                      *
  11.  **************************************************************************/
  12. /*
  13.  * Copyright 1985 by MIPS Computer Systems, Inc.
  14.  */
  15. #ifndef __SYS_SYSCALL_H__
  16. #define __SYS_SYSCALL_H__
  17. #ident    "$Revision: 1.39 $"
  18.  
  19. #if defined(_LANGUAGE_ASSEMBLY)
  20. /*
  21.  * SYSCALL -- standard system call sequence
  22.  * The kernel expects arguments to be passed with the normal C calling
  23.  * sequence.  v0 should contain the system call number.  On return from
  24.  * the kernel mode, a3 will be 0 to indicate no error and non-zero to
  25.  * indicate an error; if an error occurred v0 will contain an errno.
  26.  * WARNING - restartable system call conventions REQUIRES that the li of
  27.  * v0 is immediately before the syscall instrcution
  28.  */
  29.     .globl    _cerror
  30. #if (_MIPS_SIM == _ABIO32)
  31.     .globl    _cerror64
  32. #endif /* _MIPS_SIM == _ABIO32 */
  33.  
  34. #if (_MIPS_SIM == _ABIO32)
  35. #define JCERROR                        \
  36.     LA    t9, _cerror;                \
  37.     j    t9
  38. #define JCERROR64                    \
  39.     LA    t9, _cerror64;                \
  40.     j    t9
  41. #endif /* _MIPS_SIM == _ABIO32 */
  42.  
  43. #if (_MIPS_SIM == _ABI64 || _MIPS_SIM == _ABIN32)
  44. #define JCERROR                        \
  45.     LA    t9, _cerror;                \
  46.     .cpreturn;                    \
  47.     j    t9
  48. #endif /* _MIPS_SIM == _ABI64 || _MIPS_SIM == _ABIN32 */
  49.  
  50. #ifdef _PIC
  51.  
  52. #if (_MIPS_SIM == _ABIO32)
  53. #define EPILOGUE                                        \
  54.         .set    noreorder;                              \
  55. 9:                                                      \
  56.         move    t8, ra;         /* save old ra */       \
  57.         bal     10f;            /* find addr of cpload */\
  58.         nop;                                            \
  59. 10:                                                     \
  60.         .cpload ra;                                     \
  61.         move    ra, t8;                                 \
  62.         .set    reorder;                                \
  63.         JCERROR
  64.  
  65. #define EPILOGUE64                                      \
  66.         .set    noreorder;                              \
  67. 9:                                                      \
  68.         move    t8, ra;         /* save old ra */       \
  69.         bal     10f;            /* find addr of cpload */\
  70.         nop;                                            \
  71. 10:                                                     \
  72.         .cpload ra;                                     \
  73.         move    ra, t8;                                 \
  74.         .set    reorder;                                \
  75.         JCERROR64
  76. #endif /* _MIPS_SIM == _ABIO32 */
  77.  
  78. #if (_MIPS_SIM == _ABI64 || _MIPS_SIM == _ABIN32)
  79. #define EPILOGUE                    \
  80.     .set    noreorder;                \
  81.         .cplocal    t0;                \
  82. 9:                            \
  83.     move    t8, ra;        /* save old ra */    \
  84.     bal    10f;        /* find addr of cpload */\
  85.     nop;                        \
  86. 10:                            \
  87.         .cpsetup    ra, t0, 10b;            \
  88.     .set    reorder;                \
  89.     move    ra, t8;                    \
  90.     LA    t9, _cerror;                \
  91.         j    t9
  92.  
  93. #endif /*  _MIPS_SIM == _ABI64 || _MIPS_SIM == _ABIN32 */
  94.  
  95. #else /* _PIC */
  96.  
  97. #define EPILOGUE                    \
  98. 9:                            \
  99.     .set    reorder;                \
  100.     JCERROR
  101.  
  102. #if (_MIPS_SIM == _ABIO32)
  103. #define EPILOGUE64                    \
  104. 9:                            \
  105.     .set    reorder;                \
  106.     JCERROR64
  107. #endif    /* _MIPS_SIM == _ABIO32 */
  108.  
  109. #endif /* _PIC */
  110.  
  111. #define SYSCALL(x)    GSYSCALL(x,x)
  112. #define PSEUDO(x,y)    GSYSCALL(x,y)
  113.  
  114. #define    GSYSCALL(x,y)                    \
  115. .weakext    x, _/**/x;                \
  116. LEAF(_/**/x);                        \
  117.     .set    noreorder;                \
  118.     li    v0,SYS_/**/y;                \
  119.     syscall;                    \
  120.     bne    a3,zero,9f;                \
  121.     nop;
  122.  
  123. #define    RET(x)                        \
  124.     j    ra;                    \
  125.     nop;                        \
  126.     EPILOGUE;                    \
  127.     .end    _/**/x
  128.  
  129. #if (_MIPS_SIM == _ABIO32)
  130. #define    RET64(x)                    \
  131.     j    ra;                    \
  132.     nop;                        \
  133.     EPILOGUE64;                    \
  134.     .end    _/**/x
  135. #endif /* _MIPS_SIM == _ABIO32 */
  136.  
  137. #endif /* ASSEMBLY */
  138.  
  139. /*
  140.  * Rest of file for /proc system call tracing and kernel syscall table
  141.  */
  142. #if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
  143. #include "sys/types.h"
  144. #include <sys.s>    /* syscall numbers with kernel offset SYSVoffset */
  145.  
  146. #ifndef _KERNEL
  147. /*
  148.  * The /proc syscall numbers start from 2 onwards. 2 corresponds to bit 1
  149.  * (assuming an integer's bits are numbered 0..31 with 0 being the LSB)
  150.  * in sysset_t since it gets decremented by 1 in praddset (sys/procfs.h).
  151.  * Thus we maintain compatibility with the old /debug syscall numbers
  152.  * (which start with 1) since the same bit would be set for both 
  153.  * the /debug and /proc interfaces.
  154.  */
  155. #undef SYSVoffset
  156. #define SYSVoffset    1
  157. #endif /* !_KERNEL */
  158.  
  159. typedef struct {
  160.     __uint32_t word[16];
  161. } sysset_t;
  162.  
  163.  
  164. #if defined(_SGI_SOURCE) || defined (_KERNEL)
  165. /*
  166.  * system call argument encoding - used by par(1)
  167.  */
  168. typedef unsigned short sysargdesc_t;
  169.  
  170. /*
  171.  * top 4 bits are arg#
  172.  * next 4 bits are type
  173.  * bottom 8 bits are size
  174.  * a 0 implies that the arg is passed by value rather than by reference
  175.  * NOTE - we use arg #'s 1-n so various macros subtract 1 to get an
  176.  * array index.
  177.  */
  178. /* arg numbers */
  179. #define SY_GETARG(x)    ((((x) >> 12) & 0xf) -1)
  180. #define SY_ARG(x)    (x<<12)    /* arg #x */
  181.  
  182. /* types */
  183. #define SY_GETTYPE(x)    ((x) & 0x0f00)
  184. #define SY_STRING    (1<<8)    /* arg is null terminated string */
  185. #define SY_OUTSTRING    (2<<8)    /* arg is returned string */
  186. #define SY_IN        (3<<8)    /* arg pts to fixed # of bytes */
  187. #define SY_OUT        (4<<8)    /* arg pts to fixed # of bytes (output) */
  188. #define SY_INSPECIAL    (5<<8)    /* special difficult decoding - use bottom
  189.                  * bits to index into special table
  190.                  */
  191. #define SY_OUTSPECIAL    (6<<8)    /* special difficult decoding - output */
  192. #define SY_OUTV        (7<<8)    /* arg pts to variable # of bytes */
  193. #define SY_INV        (8<<8)    /* arg pts to variable # of bytes -
  194.                  * bottom bits says which arg to use
  195.                  */
  196. #define SY_OUTVI    (9<<8)    /* arg pts to variable # of bytes
  197.                  * which is given by a value-result parm
  198.                  * an arg # 0 means use rval1
  199.                  */
  200.  
  201. #define SY_GETSIZE(x)    ((x) & 0xff)
  202.  
  203. /* SY_VARIABLE encodes variable # in 'size' field */
  204. #define SY_GETVARG(x)    (((x) & 0xff) - 1)
  205. #define SY_VARG(x)    (x)
  206.  
  207. /* SY_SPECIAL - encode special table index in 'size' field */
  208. #define SY_GETSPIDX(x)    ((x) & 0xff)
  209. #define SY_SPIDX(x)    (x)
  210.  
  211. #endif
  212.     
  213. #ifdef _KERNEL
  214.  
  215. /*
  216.  * Structure of the system-entry table
  217.  */
  218. extern struct sysent {
  219.     char    sy_narg;    /* total number of arguments */
  220.     char    sy_flags;    /* various flag bits (see below) */
  221.     int    (*sy_call)();    /* handler */
  222.     sysargdesc_t *sy_argdesc; /* descriptors for args */
  223. } sysent[], irix5_64_sysent[];
  224.  
  225. #define    SY_INDIR    0x02    /* another routine will do demultiplexing */
  226. #define SY_SPAWNER    0x04    /* syscall creates new processes (for PROF) */
  227. #define SY_64BIT_ARG    0x08    /* Tell o32 kernel syscall has 64bit arg */
  228. #define    SY_FULLRESTORE    0x10    /* restore all regs */
  229. #define SY_NOXFSZ    0x40    /* do not send SIGXFSZ if EFBIG error */
  230. #define SY_NORESTART    0x80    /* don't restart these syscalls */
  231.  
  232. /*
  233.  * Per-process system call handler info
  234.  */
  235. struct syscallsw {
  236.     struct    sysent    *sc_sysent;        /* pointer to sysent table */
  237.     unsigned sc_nsysent;            /* table size */
  238. };
  239.  
  240. extern struct syscallsw    syscallsw[];        /* defined in os/main.c */
  241. typedef    int (*sy_call_t)(sysarg_t *, void *, uint);
  242.  
  243. #endif /* _KERNEL */
  244.  
  245. #endif /* language C */
  246. #endif /* __SYS_SYSCALL_H__ */
  247.